﻿using System.Linq;

namespace Friedlich.Common
{

    public class Company
    {
        
        public Enumerations.CompanyType CompanyType { get; set; }
        public string Size { get; set; }
        public string Name { get; set; }
        public string Industry { get; set; }

        public bool IsMatch(string companyName) {            
            string[] nameSplit = companyName.Split(' ');
            double matchCount = 0;
            foreach (var nameSegment in nameSplit)
            {
                if(Name.ToLowerInvariant().Contains(nameSegment.ToLowerInvariant())){
                    matchCount = matchCount + nameSegment.Length;
                }                   
            }
            return (matchCount > 0) && (((Name.Length - nameSplit.Length) / matchCount) >= .8);            
        }

    }
}
